package com.example.dryyzx.dao;

import com.example.dryyzx.entity.NursingRecord;
import org.apache.ibatis.jdbc.SQL;

public class NursingRecordSqlProvider {
    public String insertSelective(NursingRecord record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("nursing_record");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getCustomerId() != null) {
            sql.VALUES("customer_id", "#{customerId,jdbcType=INTEGER}");
        }
        
        if (record.getNurseId() != null) {
            sql.VALUES("nurse_id", "#{nurseId,jdbcType=INTEGER}");
        }
        
        if (record.getNursingContentId() != null) {
            sql.VALUES("nursing_content_id", "#{nursingContentId,jdbcType=INTEGER}");
        }
        
        if (record.getStartTime() != null) {
            sql.VALUES("start_time", "#{startTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getEndTime() != null) {
            sql.VALUES("end_time", "#{endTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getEnable() != null) {
            sql.VALUES("enable", "#{enable,jdbcType=BIT}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(NursingRecord record) {
        SQL sql = new SQL();
        sql.UPDATE("nursing_record");
        
        if (record.getCustomerId() != null) {
            sql.SET("customer_id = #{customerId,jdbcType=INTEGER}");
        }
        
        if (record.getNurseId() != null) {
            sql.SET("nurse_id = #{nurseId,jdbcType=INTEGER}");
        }
        
        if (record.getNursingContentId() != null) {
            sql.SET("nursing_content_id = #{nursingContentId,jdbcType=INTEGER}");
        }
        
        if (record.getStartTime() != null) {
            sql.SET("start_time = #{startTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getEndTime() != null) {
            sql.SET("end_time = #{endTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getEnable() != null) {
            sql.SET("enable = #{enable,jdbcType=BIT}");
        }
        
        sql.WHERE("id = #{id,jdbcType=INTEGER}");
        
        return sql.toString();
    }
}